/******************************************************************************
 * * sms_global.h - data structure for sms module
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#ifndef SMS_GLOBAL_H
#define SMS_GLOBAL_H

#ifdef __cplusplus
extern "C" {
#endif

#define SMS_TIME_MAX_LEN 20

enum {
    MSG_DICTIONARY_ENABLE = 0,
    MSG_DICTIONARY_OFF
};

typedef UINT8 SMS_NV_DICTIONARY_ENABLE;

enum {
    MSG_DELIVERY_REP_YES = 0,
    MSG_DELIVERY_REP_NO
};

typedef UINT8 SMS_NV_DELIVERY_REP;

enum {
    NO_OTHER_APP_USE = 0,
    CONTACTS_SMS_REQ,
    CONTACTS_SHARE_VIA_SMS_REQ,
    CALL_SEND_SMS_REQ,
    FRAMEWORK_SMS_OPEN_INBOX_REQ,
    FRAMEWORK_SMS_SEND_MESSAGE_REQ
};

typedef UINT8 SMS_OTHER_APP_USE_TYPE;
typedef enum {
    SMS_NO_SIM_PRESENT = 0,
    SMS_SIM1_PRESENT,
    SMS_SIM2_PRESENT,
    SMS_BOTH_SIM_PRESENT
} SMS_SIM_STATUS;                               // bitmap

typedef struct {
    UINT16 uYear;
    UINT8  uMonth;
    UINT8  uDay;
    UINT8  uHour;
    UINT8  uMinute;
    UINT8  uSecond;
    INT8   iZone;
} Msg_Tm_Sms_Time_Stamp_t;

#define TEL_NUMBER_MAX_LEN    21
typedef struct _CFW_SMS_TXT_HRD_V1_IND {
    UINT8                   oa[TEL_NUMBER_MAX_LEN];
    UINT8                   oa_size;
    UINT8                   sca[TEL_NUMBER_MAX_LEN];
    UINT8                   sca_size;
    Msg_Tm_Sms_Time_Stamp_t scts;
    UINT8                   tosca;
    UINT8                   tooa;
    UINT8                   fo;
    UINT8                   pid;
    UINT8                   dcs;
// #ifdef __NGUX_PLATFORM__	gengyue
    UINT8                   rp; // 1 is set on, 0, is set off, other is error. add by xulei 2012.06.29
    UINT16                  WaitingIndication;
#ifdef __MMI_MESSAGE_SOS__
    UINT8                   SOS; // 1 is set on, 0, is set off, other is error.
#endif
// #endif
    UINT8                   padding;
    UINT16                  nStorageId;
    UINT16                  nIndex;
    UINT16                  nDataLen;
    UINT8                   pDssata[1];
} Msg_Cfw_Sms_Txt_Hrd_V1_Ind_t;

typedef struct _CFW_EMS_INFO {
    UINT8  nMaxNum;     // Maximum number of short messages in the enhanced concatenated short message.
    UINT8  nCurrentNum; // Sequence number of the current short message
    UINT16 nRerNum;     // reference number
    UINT16 nDesPortNum; // Destination port
    UINT16 nOriPortNum; // Originator port
} Msg_Cfw_Ems_Info_t;

typedef struct _CFW_NEW_SMS_NODE {
    Msg_Cfw_Sms_Txt_Hrd_V1_Ind_t *pSmsTxtNode;
    UINT16                       nStorage;
    UINT16                       nConcatPrevIndex;
    UINT16                       nConcatCurrentIndex;
    UINT8                        nType;
} Msg_Cfw_New_Sms_Node_t;

typedef enum {
    INVAILD_ID = 0,
    MSG_CREATE_MESSAGE_BOX,
    MSG_DEL_ALL_READ,
    MSG_INBOX,
    MSG_DEL_INBOX_ONEBYONE,
    MSG_DEL_INBOX_ALLREAD,
    MSG_DEL_INBOX_ALL,
    MSG_SENT_ITEMS,
    MSG_DEL_SENT_ITEMS_ONEBYONE,
    MSG_DEL_SENT_ITEMS_ALLREAD,
    MSG_DRAFTS,
    DISTRIBUTION_LISTS,
    SCREENED_MESSAGES,
    DEL_SCREENED_MESSAGES_ONEBYONE,
    DEL_SCREENED_MESSAGES_ALLREAD,
    DEL_SCREENED_MESSAGES_ALL,
    DELETE_MESSAGES,
    MSG_COUNTER,
    MSG_SETTING,
    SERVICE_COM_EDITOR
} MSG_CURRENT_OPEN_BOX;

typedef enum {
    MSG_DICTIONARY_ENB = 0,
    MSG_DICTIONARY_SWITCH_OFF
} MSG_DICTIONARY_ENABLE_TYPE;

typedef struct {
    INT8 *pSmsc;
} MSG_SMSC_ID;

typedef enum {
    MSG_SUCCESS = 0,
    MSG_FAIL
} MSG_RESULT_TYPE;

typedef enum {
    MSG_PROCESS_NORMAL = 0,
    MSG_PROCESS_END
} MSG_PROCESS_TYPE;

typedef enum {
    MSG_USSD_CMD_SUCCESS = 0,
    MSG_USSD_UNKNOWN_CMD
} MSG_USSD_RESULT_TYPE;

typedef struct {
    MMI_MODEM_READ_SMS_TYPE SmsType;
    INT8                    *pContact;          // the contact name or phone number to display
    UINT32                  MsgIndex;           // message index on SimX or on NV
    MMI_MODEM_SIM_ID        SimId;              // it won't used by drafts
} Msg_Content_Info_t;

typedef struct {
    UINT16          Index;                      // start from 0
    INT8            *pContact;                  // the contact name
    INT8            *pNum;                      // the contact number
    MSG_RESULT_TYPE Result;                     // sent message result
} Msg_Contact_List_Info_t;

typedef struct {
    UINT32 NvAddrOffset;
    INT8   *pListName;                                          // the list name
} Msg_Distribution_List_Info_t;

typedef struct {
    UINT8   DistriCnt;
    lv_ll_t *pDisListInfo;
} Msg_Distribution_List_t;
#define MSG_INVAILD_TIMER_ID           0xFFFFFFFF
#define MSG_TIMER_LENGTH               2000
typedef struct {
#define MSG_SMSC_MAX_NUM               2
#define MSG_DRAFT_DISPLAY_LEN          15
#define MSG_INPUT_WORD_MAX_LEN         1680
#define MSG_INPUT_PHONE_NUM_MAX_LEN    20
#define MSG_INSERT_WORD_MAX_LEN        32
#define MSG_ADD_LIST_MAX_LEN           10
#define MSG_TEXT_INPUT_MAX_LEN         5
    MSG_SMSC_ID                  Smsc[MSG_SMSC_MAX_NUM];                   // the SMSC of SIM0 will be stored in Smsc[0].
    Msg_Content_Info_t           *pCurrentViewMsg;                         // the pointer of the current view message
    MSG_CURRENT_OPEN_BOX         CurOpenBox;
    INT8                         *pDistriListName;
    IF_CONTACTS_SEL_CONTACT_TYPE SelContactType;
    INT8                         *pContact;                                // the number of receiver
    INT8                         *pContactTa;
    INT8                         *pNumber;
    MMI_MODEM_SIM_ID             CurrSimId;                                // current select sim id
    lv_ll_t                      *pInboxMsgContentInfo;                    // inbox,the header of the pointer
    lv_ll_t                      *pSentboxMsgContentInfo;                  // sent items,the header of the pointer
    lv_ll_t                      *pDraftMsgContentInfo;                    // drafts,the header of the pointer
    lv_ll_t                      *pScrnMsgContentInfo;                     // screened messages,the header of the pointer
    Msg_Distribution_List_t      *pDisList;                                // distribution list,the header of the pointer
    UINT16                       ContactCnt;
    UINT16                       SuccessCnt;
    UINT16                       SendCnt;
    UINT16                       ResendCnt;
    BOOL                         ResendFlg;                                // true or false
    lv_ll_t                      *pContactInfo;                            // the header of the pointer,send to many or send to list should be used
    Msg_Contact_List_Info_t      *pCurrentSend;                            // send to many or send to list should be used
    INT8                         *pSmsText;                                // unencode message need to send
    INT8                         *pReadSmsText;
    MSG_DICTIONARY_ENABLE_TYPE   DictionaryFlg;
    BOOL                         InsertNumFlg;
    BOOL                         NewSmsFlg;
    SMS_OTHER_APP_USE_TYPE       OtherAppUseType;
    UINT16                       UnreadCnt;
    VOID                         *pChart;
    INT8                         *pTime;
    TIMER_ID                     Timerid;
} Msg_Global_Ctrl_t;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*SMS_GLOBAL_H*/
